home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / wasm201.arc / KEY.ASM < prev    next >
Assembly Source File  |  1988-07-17  |  6KB  |  167 lines

  1.  
  2.  Title 'Wolfware Assembler Sample', 'Key Reassignment'
  3.  
  4. ;========================================================;
  5. ;             Key Reassignment Version 1.10              ;
  6. ;                                                        ;
  7. ; Reassign any string to any key via DOS 2.0.  The       ;
  8. ; ANSI.SYS device driver must be installed (see your DOS ;
  9. ; manual).  Once assembled, to reassign a key, type:     ;
  10. ;                                                        ;
  11. ; KEY <key code> <string>                                ;
  12. ;                                                        ;
  13. ; The parameters must be separated by a single space.    ;
  14. ; Each parameter may consist of any combination of       ;
  15. ; strings in double quotes and decimal ASCII codes,      ;
  16. ; seperated by semicolons.                               ;
  17. ;                                                        ;
  18. ; The key to reset (first parameter) should be the       ;
  19. ; key's character code (one or two bytes).  The new      ;
  20. ; assignment (second parameter) can be any combination   ;
  21. ; of strings and ASCII values.                           ;
  22. ;                                                        ;
  23. ; Examples:                                              ;
  24. ;                                                        ;
  25. ; KEY "g" "h"                                            ;
  26. ;   Assign lower-case h to the lower-case g key.         ;
  27. ;                                                        ;
  28. ; KEY 0;59 19                                            ;
  29. ;   Assigns ^S to the F1 key.  0;59 is the key code for  ;
  30. ;   F1.  Makes F1 act like Ctl NumLock when you are,     ;
  31. ;   for instance, TYPEing out a file.                    ;
  32. ;                                                        ;
  33. ; KEY 0;68 "DIR";13                                      ;
  34. ;   Assign DIR plus a carriage return to the F10 key.    ;
  35. ;                                                        ;
  36. ; The extended codes for all applicable keys can be      ;
  37. ; found in the BASIC manual right after the ASCII        ;
  38. ; character table.  Most application programs bypass     ;
  39. ; the DOS keyboard routines (i.e. the reassignments      ;
  40. ; won't work for them).  Keyboard reaasignment by this   ;
  41. ; method is probably best used for setting up the        ;
  42. ; function keys to use from the DOS command level.       ;
  43. ;========================================================;
  44.  
  45.  Proc Far
  46.  
  47. ;----- print message
  48.  
  49.  Mov Dx, Offset Keymess ;message location
  50.  Call Str_Display       ;string display
  51.  
  52. ;----- number of characters
  53.  
  54.  Mov Cl, [Input]        ;number of characters
  55.  Sub Ch, Ch
  56.  Cmp Cl, 1              ;check if too few
  57.  Jb Keyerror            ;jump if so
  58.  
  59. ;----- print input and end CR
  60.  
  61.  Push Cx
  62.  Mov Si, Input + 2      ;start after space
  63.  Push Si
  64.  
  65.  Mov Dx, Offset Keymess2 ;message location
  66.  Call Str_Display       ;string display
  67.  
  68. Keyiloop
  69.  Lodsb                  ;load next byte
  70.  Call Display           ;display
  71.  Loop Keyiloop          ;loop CX times
  72.  
  73. ;----- move a line down
  74.  
  75.  Mov Al, 10             ;byte to display, LF
  76.  Call Display           ;display
  77.  
  78.  Pop Di
  79.  Pop Bx
  80.  
  81. ;----- scan for space
  82.  
  83.  Dec Bx                 ;do not count initial space
  84.  Mov Cx, Bx             ;number of characters to search
  85.  Mov Al,' '             ;look for space
  86.  
  87.  Repne
  88.  Scasb                  ;scan until found or no more
  89.  
  90. ;----- add semicolon
  91.  
  92.  Jne Keyerror           ;jump if not found
  93.  Mov Byte [Di-1], ';'   ;save semicolon to location
  94.  
  95. ;----- add start code
  96.  
  97.  Mov Ax, Ctl_Start      ;load starting control
  98.  Mov [Input], Ax        ;save
  99.  
  100. ;----- add end code
  101.  
  102.  Mov Ax, Ctl_End        ;load end control
  103.  Mov [Input+Bx+2], Ax   ;save
  104.  
  105. ;----- reset key
  106.  
  107.  Mov Dx, Input          ;control string location
  108.  Call Str_Display       ;string display
  109.  Jmps Exit
  110.  
  111. ;----- error in parameters
  112.  
  113. Keyerror 
  114.  Mov Dx, Offset Keyemess ;error message location
  115.  Call Str_Display       ;string display
  116.  
  117. ;----- exit
  118.  
  119. Exit
  120.  Mov Ax, 4c00h          ;function
  121.  Int 21h                ;execute
  122.  
  123. ;===============================================;
  124. ;                    Display                    ;
  125. ; Display the character in AL to the screen.    ;
  126. ;===============================================;
  127.  
  128. Display Proc Near
  129.  Mov Dl, Al             ;byte to display
  130.  Mov Ah, 2              ;display byte function
  131.  Int 21h                ;execute
  132.  Ret
  133.  Endp                   ;Display
  134.  
  135. ;===============================================;
  136. ;                   Str_Display                 ;
  137. ; Display the string at DX terminated by a      ;
  138. ; dollar sign to the screen.                    ;
  139. ;===============================================;
  140.  
  141. Str_Display Proc Near
  142.  Mov Ah, 9              ;string output function
  143.  Int 21h                ;execute
  144.  Ret
  145.  Endp                   ;Str_Display
  146.  
  147. ;===============================================;
  148. ;                  Program Data                 ;
  149. ;===============================================;
  150.  
  151. Input Equ 80h           ;parameter location
  152.  
  153. Ctl_Start Label Word
  154.  Db 27,'['              ;start of reassignment sequence
  155. Ctl_End Label Word
  156.  Db 'p$'                ;end of reassignment sequence
  157.  
  158. Keymess Db 10,'Key Reassignment Version 1.10', 13, 10,'$'
  159. Keymess2 Db '--> $'
  160.  
  161. Keyemess Db 10,'Error in parameters: <key code> <output>', 13, 10
  162.  Db '  Each parameter may consist of any combination of', 13, 10
  163.  Db '  strings in double quotes and decimal ASCII codes,', 13, 10
  164.  Db '  seperated by semicolons.', 13, 10,'$'
  165.  Endp
  166.  
  167.